"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
('use strict');
const mongoose = require("mongoose");
const common_util_1 = require("@qianmi/x-site-common/util/common-util");
let filePath = '//qianmi-web.oss-cn-hangzhou.aliyuncs.com/x-site/' + common_util_1.default.getEnvCode() + '/public/buildTemplate/${fileName}';
//创建集合模式
let TemplateInfoSchema = new mongoose.Schema({
    templateCode: { type: String, unique: true, required: true },
    templateName_cn: { type: String, required: true },
    templateName_us: { type: String, default: '' },
    detailInfo: {
        //详细信息
        previewImage: String,
        previewHtml: String,
        detailImage: String,
        author: String,
        authorHtml: String,
        browserSupport: {},
        desc: { type: String, default: '' } //当前模板的详细表述
    },
    isShow: { type: Boolean, default: true },
    keyword: [String],
    updateTime: { type: Date },
    rule4PageCode: {
        type: String,
        required: true,
        enum: ['multi', 'single', 'diy'],
        default: 'multi'
    },
    pageType: { type: String, required: true, default: 'index' },
    platform: { type: String, required: true, enum: ['pc', 'weixin', 'app', 'pad'] },
    systemCode: {
        type: String,
        required: true,
        enum: ['d2cStore', 'd2p', 'ehome']
    },
    publishType: {
        type: String,
        enum: ['index', 'index-all', 'subs', 'goodsList', 'goodsInfo']
    },
    styleType: {
        type: String,
        default: 'none',
        enum: ['none', 'standard', 'adapter']
    },
    color2Class: {},
    acceptStyles: [
        {
            name: String,
            title: String,
            background: String,
            defaultSelected: { type: Boolean, default: false },
            color: {}
        }
    ],
    isDoublePlatformTpl: { type: Boolean, default: false },
    loadingWidgetNs: { type: String, default: '' },
    acceptBars: [String],
    pluginBars: [String],
    adapterBars: [String],
    dependenciesBar: [String],
    barDefaultPropsMap: {},
    nsTransferMap: {},
    children: [],
    templateConfig: {}
});
//用虚拟字段做兼容处理
TemplateInfoSchema.virtual('id').get(function () {
    return this._id;
});
//用虚拟字段做兼容处理
TemplateInfoSchema.virtual('templateName').get(function () {
    return this.templateCode;
});
//用虚拟字段做兼容处理
TemplateInfoSchema.virtual('platForm').get(function () {
    return this.platform;
});
//文件位置是固定规则生成的 用虚拟属性返回就行了
TemplateInfoSchema.virtual('jsFile').get(function () {
    return filePath.replace('${fileName}', this.templateCode + '.js');
});
//文件位置是固定规则生成的 用虚拟属性返回就行了
TemplateInfoSchema.virtual('cssFile').get(function () {
    return filePath.replace('${fileName}', this.templateCode + '.css');
});
//确保查询结果以json返回时包含虚拟字段
TemplateInfoSchema.set('toJSON', { getters: true, virtual: true });
exports.default = TemplateInfoSchema;
